<?php
  
  class Application_Form_LoginForm extends Zend_Form
  {
      public function init()
      {
         $this->setName('user');
  
         $login = new Zend_Form_Element_Text('login');
         $login->setLabel('Login')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->setAttrib('size', 20)
                ->addValidator('StringLength',false, array(3,15))
                ->addValidator('NotEmpty');
         
          $login->getValidator('NotEmpty')->setMessages(array(
            Zend_Validate_NotEmpty::IS_EMPTY => "login nie może być pusty"
        ));
        $login->getValidator('StringLength')->setMessages(array(
            Zend_Validate_StringLength::INVALID   => "Niepoprawny napis",
            Zend_Validate_StringLength::TOO_SHORT => "login '%value%' jest zbyt krótki",
            Zend_Validate_StringLength::TOO_LONG  => "login '%value%' jest zbyt długi",
        ));
 
         $haslo = new Zend_Form_Element_Password('password');
         $haslo->setLabel('Hasło')
               ->setRequired(true)
               ->setAttrib('size', 20)
               ->addFilter('StripTags')
               ->addFilter('StringTrim')
               ->addValidator('StringLength',false, array(3,15))
               ->addValidator('NotEmpty');
         
         $haslo->getValidator('NotEmpty')->setMessages(array(
            Zend_Validate_NotEmpty::IS_EMPTY => "haslo nie może być pusty"
        ));
        $haslo->getValidator('StringLength')->setMessages(array(
            Zend_Validate_StringLength::INVALID   => "Niepoprawny napis",
            Zend_Validate_StringLength::TOO_SHORT => "haslo '%value%' jest zbyt krótki",
            Zend_Validate_StringLength::TOO_LONG  => "haslo '%value%' jest zbyt długi",
        ));
           
 
         $submit = new Zend_Form_Element_Submit('submit');
         $submit->setlabel('Zatwierdź');

         $this->addElements(array($login, $haslo, $submit));
     }
 }